package lcr;

public class Test0089 {
}

class Solution0089_1 {
    public int rob(int[] nums) {
        int length = nums.length;
        if (length <2) return nums[0];

        int pre1=nums[0], pre2=Math.max(nums[0],nums[1]);
        for (int i = 2; i < length; i++) {
            int temp = pre2;
            pre2=Math.max(pre1+nums[i],pre2);
            pre1=temp;
        }

        return pre2;
    }
}
